

package jetbrains.buildServer.server.graphql.model.connections.agent;

import graphql.execution.DataFetcherResult;
import java.util.Collections;
import java.util.List;
import jetbrains.buildServer.server.graphql.model.Agent;
import jetbrains.buildServer.server.graphql.model.connections.ExtensibleConnection;
import jetbrains.buildServer.server.graphql.model.connections.PaginatingConnection;
import jetbrains.buildServer.server.graphql.model.connections.PaginationArguments;
import jetbrains.buildServer.serverSide.SBuildAgent;
import org.jetbrains.annotations.NotNull;

public class AgentTypeAgentsConnection implements ExtensibleConnection<Agent, AgentEdge> {
  public static final AgentTypeAgentsConnection EMPTY = new AgentTypeAgentsConnection(Collections.emptyList(), PaginationArguments.everything());
  @NotNull
  private final PaginatingConnection<SBuildAgent, Agent, AgentEdge> myDelegate;

  public AgentTypeAgentsConnection(@NotNull List<SBuildAgent> data, @NotNull PaginationArguments paginationArguments) {
    myDelegate = new PaginatingConnection<>(data, AgentEdge::new, paginationArguments);
  }

  @NotNull
  @Override
  public DataFetcherResult<List<AgentEdge>> getEdges() {
    return myDelegate.getEdges();
  }

  public int getCount() {
    return myDelegate.getData().size();
  }
}